<template>
  <li :class="checked" @click="complete">
    <el-tag type="success">{{todo.date}}</el-tag>
    {{todo.content}}
    <span class="close" @click="deleteTodo">x</span>
  </li>
</template>

<script>
export default {
  props: {
    todo: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      checked: 'unchecked'
    }
  },
  methods: {
    complete () {
      if (this.checked === 'unchecked') {
        this.checked = 'checked'
      } else {
        this.checked = 'unchecked'
      }
      this.$emit('complete', this.todo.id)
    },
    deleteTodo () {
      this.$emit('del', this.todo.id)
    }
  }
}
</script>

<style scoped>
ul li {
  cursor: pointer;
  position: relative;
  padding: 12px 8px 12px 40px;
  font-size: 24px;
  transition: 0.2s;
  list-style-type: none;
  margin: 0px;
  text-align: left;
  vertical-align: middle;
  /* make the list items unselectable */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
ul li:hover {
  background: #ddd;
}
/* When clicked on, add a background color and strike out text */
ul li.checked {
  text-decoration: line-through;
}
ul li.checked::before {
  content: '';
  position: absolute;
  border-color: #00FF00;
  border-style: solid;
  border-width: 0 2px 2px 0;
  top: 16px;
  left: 16px;
  transform: rotate(45deg);
  height: 15px;
  width: 7px;
}
/* Style the close button */
.close {
  position: absolute;
  display: inline-block;
  height: 100%;
  box-sizing: border-box;
  right: 0;
  top: 0;
  padding: 12px 16px 12px 16px;
}
.close:hover {
  background-color: #f44336;
  color: white;
}
.el-tag {

}
</style>
